Draft
Conversation
change documentation to use typedoc
There was a problem hiding this comment.
Pull Request Overview
This PR rewrites the JavaScript client into TypeScript, updates build and lint configurations, and adjusts tests accordingly.
- Converts all
assets/js/phoenixsources to TypeScript and updates build output inpriv/static - Adds TypeScript support in
package.json, ESLint, and Typedoc configs - Updates test files for semicolons, imports, and TypeScript resolution
Reviewed Changes
Copilot reviewed 41 out of 49 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| typedoc.json | Added Typedoc configuration for new TS entry points |
| priv/static/phoenix.mjs | Regenerated client bundle refactored to use const/arrow and TS defaults |
| package.json | Added types, typescript, ts-jest, and new scripts for TS build |
| mix.exs | Updated assets.build alias to include TS compile step |
| eslint.config.mjs | Switched ESLint to use a TypeScript plugin and configs |
| assets/test/*.js/.ts | Updated tests with semicolons, import paths, and TS fixtures |
Comments suppressed due to low confidence (4)
package.json:51
- There’s no build step before running tests, yet tests depend on the compiled TypeScript output. Consider adding a
pretestscript such as"pretest": "npm run build"to ensure sources are transpiled before Jest runs.
"test": "jest",
typedoc.json:3
- [nitpick] Typedoc is pointing at the TS source. If you want to document the distributed API instead, consider pointing
entryPointsat the compiled declaration file (e.g.,assets/dist/phoenix/index.d.ts) to reflect the actual published API.
"entryPoints": ["./assets/js/phoenix/index.ts"],
assets/test/socket_test.js:44
- Tests reference
socket.longpollerTimeout, but the client property was renamed tolongPollFallbackMsand no default of 20000 is set. Update the test to assertsocket.longPollFallbackMsor add a backward‐compatible alias and default value.
expect(socket.longpollerTimeout).toBe(20000);
eslint.config.mjs:4
- The ESLint config is importing from
typescript-eslint, but the official plugin package is@typescript-eslint/eslint-pluginand you typically also need@typescript-eslint/parser. Update the import and parser settings accordingly.
import tseslint from "typescript-eslint";
| this.transport = opts.transport || global.WebSocket || LongPoll; | ||
| this.primaryPassedHealthCheck = false; | ||
| this.longPollFallbackMs = opts.longPollFallbackMs; | ||
| this.longPollFallbackMs = (_a = opts.longPollFallbackMs) !== null && _a !== void 0 ? _a : null; |
There was a problem hiding this comment.
Default longPollFallbackMs is set to null instead of a meaningful default (e.g., 20000ms). Consider using opts.longPollFallbackMs ?? DEFAULT_LONG_POLL_FALLBACK_MS or exposing a longpollerTimeout alias for backward compatibility with existing tests.
Suggested change
| this.longPollFallbackMs = (_a = opts.longPollFallbackMs) !== null && _a !== void 0 ? _a : null; | |
| this.longPollFallbackMs = (_a = opts.longPollFallbackMs) ?? DEFAULT_LONG_POLL_FALLBACK_MS; |
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is similar to phoenixframework/phoenix_live_view#3789, but it goes one step further and actually changes all files to typescript.
Disclaimer: Claude translated most of the files, I did manual adjustments. This is work in progress.